package com.zengdw.firstresourcemodule;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

/**
 * @Author: zengd
 * @Date: 2020/7/15 10:07
 * @Version: 1.0
 */
public class ResourceInModule {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Class<ResourceInModule> clazz = ResourceInModule.class;
        InputStream stream = clazz.getResourceAsStream("resource_in_package.txt");
        InputStream stream1 = clazz.getResourceAsStream("/top_level_resource.txt");
        byte[] bytes = new byte[1024];
        int l = 0;
        while ((l = stream.read(bytes)) != -1){
            System.out.println(new String(bytes, StandardCharsets.UTF_8));
        }

        Module m = clazz.getModule();
        InputStream inputStream = m.getResourceAsStream("com/zengdw/firstresourcemodule/resource_in_package.txt");
        InputStream inputStream1 = m.getResourceAsStream("top_level_resource.txt");
        InputStream inputStream2 = m.getResourceAsStream("resource.txt");
    }
}
